package cn.iocoder.yudao.module.question.dal.mysql.questionitem;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.question.dal.dataobject.questionitem.QuestionItemDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.question.controller.admin.questionitem.vo.*;

/**
 * 试题选项信息 Mapper
 *
 * @author MJ
 */
@Mapper
public interface QuestionItemMapper extends BaseMapperX<QuestionItemDO> {

    default PageResult<QuestionItemDO> selectPage(QuestionItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<QuestionItemDO>()
                .eqIfPresent(QuestionItemDO::getQuestionId, reqVO.getQuestionId())
                .eqIfPresent(QuestionItemDO::getQuestionType, reqVO.getQuestionType())
                .eqIfPresent(QuestionItemDO::getIsAnswer, reqVO.getIsAnswer())
                .eqIfPresent(QuestionItemDO::getItemContent, reqVO.getItemContent())
                .eqIfPresent(QuestionItemDO::getItemAnalysis, reqVO.getItemAnalysis())
                .eqIfPresent(QuestionItemDO::getItemImg, reqVO.getItemImg())
                .eqIfPresent(QuestionItemDO::getItemOrder, reqVO.getItemOrder())
                .betweenIfPresent(QuestionItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(QuestionItemDO::getId));
    }

    default List<QuestionItemDO> selectList(QuestionItemExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<QuestionItemDO>()
                .eqIfPresent(QuestionItemDO::getQuestionId, reqVO.getQuestionId())
                .eqIfPresent(QuestionItemDO::getQuestionType, reqVO.getQuestionType())
                .eqIfPresent(QuestionItemDO::getIsAnswer, reqVO.getIsAnswer())
                .eqIfPresent(QuestionItemDO::getItemContent, reqVO.getItemContent())
                .eqIfPresent(QuestionItemDO::getItemAnalysis, reqVO.getItemAnalysis())
                .eqIfPresent(QuestionItemDO::getItemImg, reqVO.getItemImg())
                .eqIfPresent(QuestionItemDO::getItemOrder, reqVO.getItemOrder())
                .betweenIfPresent(QuestionItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(QuestionItemDO::getId));
    }

}
